1. Field of the Invention
The present invention generally relates to query optimization, and, more specifically, to query optimization that accounts for virtual machine mirroring costs as part of the optimization process.
2. Description of Related Art
In a virtual machine (VM) mirroring environment, a primary VM is periodically halted and mirrored to a secondary (backup) VM. Doing so allows a client to quickly and seamlessly connect to the secondary VM if the primary VM crashes. Various VM mirroring implementations are publicly available, such as IBM® PowerHA® SystemMirror.
During VM mirroring, execution of the primary VM is typically halted, after which all state information including registers, central processing unit (CPU) contents, and modified random access memory (RAM) pages (also referred to herein as “dirty” pages) are copied by the primary VM to the secondary VM. Copying of the state information from the primary VM to the secondary VM is generally referred to herein as “flashing.” Once copied, the secondary VM acknowledges receipt of the pages of state info, and the primary VM resumes execution. In some implementations, mirroring may be performed many times a second. Techniques exist for predicting when a VM will be halted and its state information flashed to the secondary VM.
When VMs run database queries, such as in IBM's DB2, pages of temporary information are frequently used as scratchpads to help in computing a final query result. For example, a query engine may create temporary indexes, temporary hash tables, temporary results, etc. as intermediate result steps in executing a query. Memory pages containing such temporary data are typically mirrored to the secondary VM. However, this adds substantial overhead to the mirroring process, especially when the temporary data is large in size. Further, the temporary data may not be required on the secondary VM, so long as the secondary VM is able to execute the query should a failover be required.